<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class JSON::Ext::Parser - json: Ruby Standard Library Documentation</title>


<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<script src="../../js/jquery-3.2.0.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/js.cookie.min.js"></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../css/rdoc.css" rel="stylesheet">
<link href="../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
  var darkModeCsseHref = "../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-parse">#parse</a>
    <li ><a href="#method-i-source">#source</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-JSON::Ext::Parser">
    <h1 id="class-JSON::Ext::Parser" class="class">
      class JSON::Ext::Parser
    </h1>

    <section class="description">
    
<p>This is the <a href="../../JSON.html"><code>JSON</code></a> parser implemented as a C extension. It can be configured to be used by setting</p>

<pre class="ruby"><span class="ruby-constant">JSON</span>.<span class="ruby-identifier">parser</span> = <span class="ruby-constant">JSON</span><span class="ruby-operator">::</span><span class="ruby-constant">Ext</span><span class="ruby-operator">::</span><span class="ruby-constant">Parser</span>
</pre>

<p>with the method parser= in <a href="../../JSON.html"><code>JSON</code></a>.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          new(source, opts &rarr; {})
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new <a href="Parser.html"><code>JSON::Ext::Parser</code></a> instance for the string <em>source</em>.</p>

<p>It will be configured by the <em>opts</em> hash. <em>opts</em> can have the following keys:</p>

<p><em>opts</em> can have the following keys:</p>
<ul><li>
<p><strong>max_nesting</strong>: The maximum depth of nesting allowed in the parsed data structures. Disable depth checking with :max_nesting =&gt; false|nil|0, it defaults to 100.</p>
</li><li>
<p><strong>allow_nan</strong>: If set to true, allow NaN, Infinity and -Infinity in defiance of RFC 4627 to be parsed by the <a href="Parser.html"><code>Parser</code></a>. This option defaults to false.</p>
</li><li>
<p><strong>symbolize_names</strong>: If set to true, returns symbols for the names (keys) in a <a href="../../JSON.html"><code>JSON</code></a> object. Otherwise strings are returned, which is also the default. It’s not possible to use this option in conjunction with the <strong>create_additions</strong> option.</p>
</li><li>
<p><strong>create_additions</strong>: If set to false, the <a href="Parser.html"><code>Parser</code></a> doesn’t create additions even if a matching class and create_id was found. This option defaults to false.</p>
</li><li>
<p><strong>object_class</strong>: Defaults to Hash</p>
</li><li>
<p><strong>array_class</strong>: Defaults to Array</p>
</li></ul>

                              <div class="method-source-code" id="new-source">
            <pre>static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE source, opts;
    GET_PARSER_INIT;

    if (json-&gt;Vsource) {
        rb_raise(rb_eTypeError, &quot;already initialized instance&quot;);
    }
    rb_scan_args(argc, argv, &quot;1:&quot;, &amp;source, &amp;opts);
    if (!NIL_P(opts)) {
        VALUE tmp = ID2SYM(i_max_nesting);
        if (option_given_p(opts, tmp)) {
            VALUE max_nesting = rb_hash_aref(opts, tmp);
            if (RTEST(max_nesting)) {
                Check_Type(max_nesting, T_FIXNUM);
                json-&gt;max_nesting = FIX2INT(max_nesting);
            } else {
                json-&gt;max_nesting = 0;
            }
        } else {
            json-&gt;max_nesting = 100;
        }
        tmp = ID2SYM(i_allow_nan);
        if (option_given_p(opts, tmp)) {
            json-&gt;allow_nan = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
        } else {
            json-&gt;allow_nan = 0;
        }
        tmp = ID2SYM(i_symbolize_names);
        if (option_given_p(opts, tmp)) {
            json-&gt;symbolize_names = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
        } else {
            json-&gt;symbolize_names = 0;
        }
        tmp = ID2SYM(i_freeze);
        if (option_given_p(opts, tmp)) {
            json-&gt;freeze = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
        } else {
            json-&gt;freeze = 0;
        }
        tmp = ID2SYM(i_create_additions);
        if (option_given_p(opts, tmp)) {
            json-&gt;create_additions = RTEST(rb_hash_aref(opts, tmp));
        } else {
            json-&gt;create_additions = 0;
        }
        if (json-&gt;symbolize_names &amp;&amp; json-&gt;create_additions) {
            rb_raise(rb_eArgError,
                     &quot;options :symbolize_names and :create_additions cannot be &quot;
                     &quot; used in conjunction&quot;);
        }
        tmp = ID2SYM(i_create_id);
        if (option_given_p(opts, tmp)) {
            json-&gt;create_id = rb_hash_aref(opts, tmp);
        } else {
            json-&gt;create_id = rb_funcall(mJSON, i_create_id, 0);
        }
        tmp = ID2SYM(i_object_class);
        if (option_given_p(opts, tmp)) {
            json-&gt;object_class = rb_hash_aref(opts, tmp);
        } else {
            json-&gt;object_class = Qnil;
        }
        tmp = ID2SYM(i_array_class);
        if (option_given_p(opts, tmp)) {
            json-&gt;array_class = rb_hash_aref(opts, tmp);
        } else {
            json-&gt;array_class = Qnil;
        }
        tmp = ID2SYM(i_decimal_class);
        if (option_given_p(opts, tmp)) {
            json-&gt;decimal_class = rb_hash_aref(opts, tmp);
        } else {
            json-&gt;decimal_class = Qnil;
        }
        tmp = ID2SYM(i_match_string);
        if (option_given_p(opts, tmp)) {
            VALUE match_string = rb_hash_aref(opts, tmp);
            json-&gt;match_string = RTEST(match_string) ? match_string : Qnil;
        } else {
            json-&gt;match_string = Qnil;
        }
    } else {
        json-&gt;max_nesting = 100;
        json-&gt;allow_nan = 0;
        json-&gt;create_additions = 0;
        json-&gt;create_id = rb_funcall(mJSON, i_create_id, 0);
        json-&gt;object_class = Qnil;
        json-&gt;array_class = Qnil;
        json-&gt;decimal_class = Qnil;
    }
    source = convert_encoding(StringValue(source));
    StringValue(source);
    json-&gt;len = RSTRING_LEN(source);
    json-&gt;source = RSTRING_PTR(source);;
    json-&gt;Vsource = source;
    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-parse" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          parse()
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Parses the current <a href="../../JSON.html"><code>JSON</code></a> text <em>source</em> and returns the complete data structure as a result. It raises <a href="../ParserError.html"><code>JSON::ParserError</code></a> if fail to parse.</p>

                              <div class="method-source-code" id="parse-source">
            <pre>static VALUE cParser_parse(VALUE self)
{
  char *p, *pe;
  int cs = EVIL;
  VALUE result = Qnil;
  GET_PARSER;


#line 1946 &quot;parser.c&quot;
        {
        cs = JSON_start;
        }

#line 845 &quot;parser.rl&quot;
  p = json-&gt;source;
  pe = p + json-&gt;len;

#line 1955 &quot;parser.c&quot;
        {
        if ( p == pe )
                goto _test_eof;
        switch ( cs )
        {
st1:
        if ( ++p == pe )
                goto _test_eof1;
case 1:
        switch( (*p) ) {
                case 13: goto st1;
                case 32: goto st1;
                case 34: goto tr2;
                case 45: goto tr2;
                case 47: goto st6;
                case 73: goto tr2;
                case 78: goto tr2;
                case 91: goto tr2;
                case 102: goto tr2;
                case 110: goto tr2;
                case 116: goto tr2;
                case 123: goto tr2;
        }
        if ( (*p) &gt; 10 ) {
                if ( 48 &lt;= (*p) &amp;&amp; (*p) &lt;= 57 )
                        goto tr2;
        } else if ( (*p) &gt;= 9 )
                goto st1;
        goto st0;
st0:
cs = 0;
        goto _out;
tr2:
#line 820 &quot;parser.rl&quot;
        {
        char *np = JSON_parse_value(json, p, pe, &amp;result, 0);
        if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
    }
        goto st10;
st10:
        if ( ++p == pe )
                goto _test_eof10;
case 10:
#line 1999 &quot;parser.c&quot;
        switch( (*p) ) {
                case 13: goto st10;
                case 32: goto st10;
                case 47: goto st2;
        }
        if ( 9 &lt;= (*p) &amp;&amp; (*p) &lt;= 10 )
                goto st10;
        goto st0;
st2:
        if ( ++p == pe )
                goto _test_eof2;
case 2:
        switch( (*p) ) {
                case 42: goto st3;
                case 47: goto st5;
        }
        goto st0;
st3:
        if ( ++p == pe )
                goto _test_eof3;
case 3:
        if ( (*p) == 42 )
                goto st4;
        goto st3;
st4:
        if ( ++p == pe )
                goto _test_eof4;
case 4:
        switch( (*p) ) {
                case 42: goto st4;
                case 47: goto st10;
        }
        goto st3;
st5:
        if ( ++p == pe )
                goto _test_eof5;
case 5:
        if ( (*p) == 10 )
                goto st10;
        goto st5;
st6:
        if ( ++p == pe )
                goto _test_eof6;
case 6:
        switch( (*p) ) {
                case 42: goto st7;
                case 47: goto st9;
        }
        goto st0;
st7:
        if ( ++p == pe )
                goto _test_eof7;
case 7:
        if ( (*p) == 42 )
                goto st8;
        goto st7;
st8:
        if ( ++p == pe )
                goto _test_eof8;
case 8:
        switch( (*p) ) {
                case 42: goto st8;
                case 47: goto st1;
        }
        goto st7;
st9:
        if ( ++p == pe )
                goto _test_eof9;
case 9:
        if ( (*p) == 10 )
                goto st1;
        goto st9;
        }
        _test_eof1: cs = 1; goto _test_eof;
        _test_eof10: cs = 10; goto _test_eof;
        _test_eof2: cs = 2; goto _test_eof;
        _test_eof3: cs = 3; goto _test_eof;
        _test_eof4: cs = 4; goto _test_eof;
        _test_eof5: cs = 5; goto _test_eof;
        _test_eof6: cs = 6; goto _test_eof;
        _test_eof7: cs = 7; goto _test_eof;
        _test_eof8: cs = 8; goto _test_eof;
        _test_eof9: cs = 9; goto _test_eof;

        _test_eof: {}
        _out: {}
        }

#line 848 &quot;parser.rl&quot;

  if (cs &gt;= JSON_first_final &amp;&amp; p == pe) {
    return result;
  } else {
    rb_enc_raise(EXC_ENCODING eParserError, &quot;unexpected token at &#39;%s&#39;&quot;, p);
    return Qnil;
  }
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-source" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          source()
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a copy of the current <em>source</em> string, that was used to construct this <a href="Parser.html"><code>Parser</code></a>.</p>

                              <div class="method-source-code" id="source-source">
            <pre>static VALUE cParser_source(VALUE self)
{
    GET_PARSER;
    return rb_str_dup(json-&gt;Vsource);
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is a service of <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>, purveyors of fine <a href='https://jamesbritt.bandcamp.com/'>dance noise</a></p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

